package com.wjf.shortlink.admin.toolkit;

import java.security.SecureRandom;

public class RandomGenerator {
    private static final String CHARACTERS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    private static final SecureRandom RANDOM = new SecureRandom();

    // 生成随机分组ID
    public static String generatorRandom() {
        return generatorRandom(6);
    }

    // 生成随机分组ID
    private static String generatorRandom(int length) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < length; i++) {
            int randomIndex = RANDOM.nextInt(CHARACTERS.length());
            sb.append(CHARACTERS.charAt(randomIndex));
        }
        return sb.toString();
    }
}
